repo: Optimize memory use of `ostree_repo_list_objects()`
authorColin Walters <walters@verbum.org>
Wed, 8 Jun 2022 00:30:09 +0000 (20:30 -0400)
committerColin Walters <walters@verbum.org>
Wed, 8 Jun 2022 00:35:37 +0000 (20:35 -0400)
commitc2baa6d10b18178643bb3b40447343a22165752a
tree02b530e66af73aaa59e9b3b3c592d3c106758394
parent2b6f506f708ce78a0c204133380f865c74a7b207
repo: Optimize memory use of `ostree_repo_list_objects()`

I was looking at https://github.com/ostreedev/ostree/pull/2632
and confused at the usage of
`GVariant *value = g_variant_new ("(b@as)", TRUE, g_variant_new_strv (NULL, 0));`
which looked strange - why the empty strv?

It turns out that this is a historical legacy of the time when
ostree had pack files.  And nothing actually cares about the values
of these variants; we should have an API that returns a proper set,
and not a hash.

But...since all of these things have exactly the same value, instead
of allocating lots of redundant copies on the heap, just have
them all hold a refcount on a shared value.

This cuts the heap usage from 20MB to 13MB on a test FCOS repository
build.
src/libostree/ostree-repo.c